package com.xwltz.core.utils;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.digest.DigestAlgorithm;
import cn.hutool.crypto.digest.DigestUtil;
import cn.hutool.crypto.digest.Digester;
import com.xwltz.core.constants.Constants;

import java.security.MessageDigest;

/**
 * @description SecurityUtils
 * @information on version 1.0 be created by @xwltz at 2021/12/28 16:24
 */

@SuppressWarnings("unused")
public class SecureUtils extends SecureUtil {

	public static String password(String password, String salt) {
		String passwordStr = DigestUtil.md5Hex16(password);
		String saltStr = DigestUtil.md5Hex(salt);
		byte[] getPass = (saltStr + passwordStr + saltStr).getBytes();
		String check = DigestUtil.md5Hex16(getPass);
		System.out.println(check);
		return check;
	}

	/**
	 * 是否为管理员
	 *
	 * @param userId 用户ID
	 * @return 结果
	 */
	public static boolean isAdmin(Long userId) {
		return userId != null && 1L == userId;
	}
}
